<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./js/jquery.min.js"></script>

    <link rel="stylesheet" href="./css/商品首页.css">
    <style>
      
    </style>
</head>
<body>
    <div class="he">万峰智慧</div>
    <input placeholder="请输入您想比价的产品">
    <button>搜索</button>

    <ul class="box">
        <!-- <li>
            <img src="../瀑布流/15.jpg">
            <span>比价搜索</span>
        </li>
        <li>222</li>
        <li>222</li> -->
   
    </ul>

    <P>超值折扣推荐</P>


   <ul class="ko">
    <!-- <li>
        <img src="../瀑布流/1.jpg">
        <h4>移动端凑单品：海天 纤维 生抽 1.28了<span>1.09元</span></h4>
      <div class="di">京东商城|10-25 14：20</div>
      <div class="di2">有人评论</div>

    </li> -->

   </ul>
   <script src="./js/封装函数.js"></script>
    <script>
        
        var box =document.querySelector('.box')
        let xhr=new XMLHttpRequest()
        xhr.open('get','http://chst.vip:1234/api/getindexmenu')
        xhr.onload=function(){
            if(xhr.status===200){
                let res=JSON.parse(xhr.responseText)
            // console.log(res.result)
            var lis=''
            let regExp = /^<[^<]+\s+src="([^''""]*)"/;

            res.result.forEach((element,ind) => {
            let tu = res.result[ind].img.match(regExp)[1];
            // console.log(tu)

                lis+=`
                <li>
                    
                    <img src="http://chst.vip:8081/for-stu/wfzh/${tu}">
                    <span>${element.name}</span>
                    </li>
                
                
                
                `
                
            })
            box.innerHTML=lis
            setInterval(function(){
                $('.box li').eq(random(0,11)).css('color',yanse())
                $('.box li').eq(random(0,11)).css('border-color',yanse())

        },10)


           
          
             $(function(){
            
            
            var flag=true
            $('.box>li').eq(7).click(function(){
                if(flag){
                    $(this)
                    .parent().animate({
                       height:130
                
                    })
                 flag=false
                }else{
                    $(this)
                    .parent().animate({
                       height:300
                
                    })
                    flag=true
                }
               

                })
               
        
                $('.box li').eq(5).click(function(){
                        
                        location.href='./优惠券页面.html'
                        })
                $('.box li').eq(10).click(function(){
                        
                        location.href='./商城导航.html'
                        })
                        
                 $('.box li').eq(8).click(function(){
                        
                        location.href='./凑单品.html'
                        })
                        
                        $('.box li').eq(11).click(function(){
                        
                        location.href='./品牌列表.html'
                        })

         
                $('.box li').eq(2).click(function(){
                        
                        location.href='./国内折扣.html'
                        })

                 $('.box li').eq(3).click(function(){
                        
                        location.href='./白菜价.html'
                        })

                $('.box li').eq(0).click(function(){
            
                    location.href='./分类页.html'
                })

                $('.box li').eq(1).click(function(){
                    
                    location.href='./省钱控.html'
                })
                    })
                    

                    }
                }
               

               xhr.send()


            var ko=document.querySelector('.ko')
            let xhr1=new XMLHttpRequest()
            xhr1.open('get',`http://chst.vip:1234/api/getmoneyctrl`,true,)
            xhr1.onload=function(){

            if(xhr1.status===200){
                var res2=JSON.parse(xhr1.responseText)
                //  console.log(res2.result)
            let regExp = /^<[^<]+\s+src="([^''""]*)"/;

                 var lis2=''
        
                 res2.result.forEach(function(so,ind){
                 let tu = res2.result[ind].productImgSm.match(regExp)[1].split('=')[2];
            //    console.log(tu)
                lis2+=`
                <li productid="${so.productId}">
              <img src="${tu}">
              <h4>${so.productName}<span>${so.productPinkage}</span></h4>
              <div class="di">${so.productFrom}</div>
              <div class="di2">${so.productComCount}</div>

         </li>          
                  
               `
            })
            }
            ko.innerHTML=lis2

        $('.ko li').click(function(e){

                
        var e=e||window.event
        var target=e.target||e.srcElement
        
        if(target.nodeName==="LI"){

            localStorage.setItem("productid",target.getAttribute('productid'))
           

        }
        else{
            localStorage.setItem("productid",target.parentNode.getAttribute('productid'))
         
            
        }
        location.href="./超值折扣推荐详情页.html"
     
        })






        }
            
        xhr1.send()

        

    
     

    </script>
    
</body>
</html>